.netCHARTING v5.1 Documentation Send comments on this topic.
Axis Scales
Getting Started > General Tutorials > Axis Tutorials > Axis Scales

Glossary Item Box

Axis Scales


Introduction
This section will describe the following:


Scale Types

Axis scales dictate more than just the values on an axis. They also specify element behavior such as stacked, or FullStacked. The options for the Scale enumeration include:

Between numeric and time scales, .netCHARTING will automatically set the appropriate scale so it does not always need to be specified explicitly. Scales such as Stacked or FullStacked only apply to axes on which the element y values are plotted because these are the values that are stacked. For example with a combo chart, the Chart.YAxis would be the one to specify a stacked scale.

Other properties that control the scale include:


Intervals

Intervals come in two flavors, numeric, and time. The latter is more complicated so we’ll tackle numeric first.

Controlling the interval is a simple concept. You can specify a numeric interval using code such as:

[C#]

Chart.YAxis.Interval = 5;
[Visual Basic]

Chart.YAxis.Interval = 5

 

This will force an interval at every five numeric units. Other interval related properties include:


Time interval

The basic time interval is controlled with the Axis.TimeInterval property

[C#]

Axis.TimeInterval = TimeInterval.Week;
[Visual Basic]

Axis.TimeInterval = TimeInterval.Week

 

Advanced time interval

A more complex time interval is also available and can be specified through the Axis.TimeIntervalAdvanced property.

Multiplier

Using the advanced time interval version allows you to specify an interval multiplier. For example we can have an interval every 4 days or 2 weeks etc.

[C#]

Axis.TimeIntervalAdvanced.Multiplier = 2;
[Visual Basic]

Axis.TimeIntervalAdvanced.Multiplier = 2

Custom time span

A completely custom time span can be used as a time interval.

[C#]

Axis.TimeIntervalAdvanced.TimeSpan = new TimeSpan(10,5,3);
[Visual Basic]

Axis.TimeIntervalAdvanced.TimeSpan = New TimeSpan(10,5,3)

 

Custom start time

An interval can also start at any given time. These times can be specified through the following properties:


Ranges

The scale’s numeric, time, and category axis boundaries can be specified using the Axis.ScaleRange property. New in version 5.0, the scale range can also represent a range on a category axis.

[C#]

Chart.YAxis.ScaleRange.ValueHigh = 100;
Chart.YAxis.ScaleRange.ValueLow = 2;
//Or
Chart.YAxis.ScaleRange.ValueHigh = new DateTime(2000,12,1);
Chart.YAxis.ScaleRange.ValueLow = new DateTime(2000,1,1);
[Visual Basic]

Chart.YAxis.ScaleRange.ValueHigh = 100
Chart.YAxis.ScaleRange.ValueLow = 2
'Or
Chart.YAxis.ScaleRange.ValueHigh = New DateTime(2000,12,1)
Chart.YAxis.ScaleRange.ValueLow = New DateTime(2000,1,1)

Providing a single high or low value without its counterpart is also permitted.

[C#]

YAxis.ScaleRange.ValueLow = 2;
[Visual Basic]

YAxis.ScaleRange.ValueLow = 2;
Note: Numeric intervals start at zero, therefore, if the minimum value doesn’t land on an interval there may be a gap between the scale’s edge and the first axis tick.

Category Axis Scale Ranges

New in version 5.0, the scale range can also represent a category axis range. It can achieved in two ways. The axis tick label text can be used to specify the range. The other way is to use a zero-based indexes to reference the axis ticks. For example, if there are 10 axis ticks they can be referenced using a numeric index of [0-9]. This code demonstrates the two methods.

[C#]

// Using names. Chart.XAxis.ExtraTicks.Add(new AxisTick("Element 1", "Element 3", "Range")); // Using indexes. Chart.XAxis.ExtraTicks.Add(new AxisTick(0, 2, "Range"));
[Visual Basic]

' Using names. Chart.XAxis.ExtraTicks.Add(New AxisTick("Element 1", "Element 3", "Range")) ' Using indexes. Chart.XAxis.ExtraTicks.Add(New AxisTick(0, 2, "Range"))


Time Scale Padding

Time scale ranges can be padded with an equal amount of time on either side of the plotted data to produce the final range. This is achieved using Axis.TimePadding.

[C#]

Chart.XAxis.TimePadding = TimeSpan.FromDays(10);
[Visual Basic]

Chart.XAxis.TimePadding = TimeSpan.FromDays(10)

 

Scale Breaks

Scale breaks are discontinuities in an axis' scale. They are useful in the following scenarios:


For the first two cases, the chart engine can automatically generate a scale break by setting Axis.SmartScaleBreak to true.

Sample: AxisScaleBreaks.aspx

Scale breaks are added manually like so:

[C#]

Axis.ScaleBreaks.Add( new ScaleRange(0,50) );
//Or for time:
Axis.ScaleBreaks.Add( new ScaleRange(new DateTime(2000,1,1), new DateTime(2000,12,1) ) );
[Visual Basic]

Axis.ScaleBreaks.Add( New ScaleRange(0,50) )
'Or for time:
Axis.ScaleBreaks.Add( New ScaleRange(New DateTime(2000,1,1), New DateTime(2000,12,1) ) )


 

Sample: AxisScaleBreaksManual.aspx

 

Scale Break Styles

A number of options are available to achieve the scale break style your charts require. The style can be set with the ScaleBreakStyle enumeration at the axis level as shown below.

[C#]

Chart.YAxis.ScaleBreakStyle = ScaleBreakStyle.ZigZag;
[Visual Basic]

Chart.YAxis.ScaleBreakStyle = ScaleBreakStyle.ZigZag
Sample: AxisScaleBreakStyling.aspx


Scale Influentials
Objects that inherit from ScaleRange, such as AxisMarker and AxisTicks are able to influence the axis’ scale range. For instance, a chart showing bandwidth usage over a period of time with an axis marker representing the bandwidth limit may have elements that will never reach or even come close to the limit marker’s value. Because of this, the limit marker will not be visible on the chart; however, if AxisMarker.IncludeInAxisScale is true, the marker will tell the axis scale range to encompass its value.

Objects that can influence axis scales are:

Sample: AxisAffectScale.aspx
©2002 - 2008 Webavail Productions Inc. & Corporate Web Solutions Ltd. All Rights Reserved.